package com.mldong.modules.sys.tasks;

import cn.hutool.core.util.RandomUtil;
import com.mldong.sse.SseModel;
import com.mldong.sse.SseService;
import com.mldong.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class SseTaskRunner implements TimerTaskRunner {
    private final SseService sseService;
    @Override
    public void action() {
        SseModel model = SseModel.builder().userId(RandomUtil.randomLong()).type("test").msg("消息提醒测试").build();
        sseService.broadcast(model);
    }

    @Override
    public String getCron() {
        return "0/10 * * * * ?";
    }

    @Override
    public boolean isXxlJob() {
        return false;
    }

    @Override
    public String getName() {
        return "sse消息推送";
    }
}
